package 华为面试;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 @author fujiangnan
 @create 2021-09-28-08-13
 @desc ...
 */
public class Main {
    public static void main(String[] args) {
        int[] arr = {4,3,2,7,8,2,3,1};
        List list = method(arr);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

    public static List method(int[] arr) {
        if (arr == null) {
            return null;
        }
       List<Integer> ans = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            int index = Math.abs(arr[i])-1;
            if (arr[index] > 0) {
                arr[index] = -arr[index];
            } else {
                ans.add(index+1);
            }
        }
        return ans;
    }
}
